<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/jquery.min.js"></script>
	</head>
	<body>
		<div>商品编号：<span id="itemId"></span></div>
		<div>商品价格：<span id="itemPrice"></span></div>
	</body>
	<script>
		//jquery提供ajax，参数是一个js对象{}
		$.ajax({
			type:"POST",//发起一个POST请求
			url:"https://p.3.cn/prices/mgets?skuIds=J_100014323002",
			data:{//参数又是一个js对象
				"skuIds":"J_100014323002"
			},
			contentType:"application/jaon;charset=utf-8;",
			dataType:"jsonp",
			success:function(data){
				console.log("访问成功")
				console.log(data)
				
				//解析id和price
				var item = data[0];//获取到这条记录
				
				var itemId = item.id;
				var itemPrice = item.p;
				console.log(itemId);
				console.log(itemPrice);
				
				var id = $("#itemId");
				id.text(itemId);
				id.css("color","blue");
				
				var price = $("#itemPrice");
				price.text(itemPrice);
				price.css("color","red");
			},
			error:function(e){
				console.log("访问失败")
			},
		})
	</script>
</html>
